/**
 * 自动引入API
 * */
import AutoImport from 'unplugin-auto-import/vite'
import IconsResolver from 'unplugin-icons/resolver'

export function configAutoImport() {
  return AutoImport({
    include: [
      /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
      /\.vue$/,
      /\.vue\?vue/, // .vue
    ],
    imports: [
      'vue',
      'pinia',
      'vue-router',
      'uni-app',
      {
        dayjs: [['default', 'dayjs']],
        'lodash-es': ['cloneDeep'],
        'axios': [
          // default imports
          ['default', 'axios'], // import { default as axios } from 'axios',
        ],
        '[package-name]': [
          '[import-names]',
          // alias
          ['[from]', '[alias]'],
        ],
      },
      // example type import
      {
        from: 'vue-router',
        imports: ['RouteLocationRaw'],
        type: true,
      },
    ],
    resolvers: [
      IconsResolver({
        enabledCollections: []
      })
    ],
    eslintrc: {
      enabled: false,
      filepath: './config/unplugin/.eslintrc-auto-import.json'
    },
    dts: './config/unplugin/auto-imports.d.ts'
  })
}
